use std::collections::HashSet;

struct Solution {}

fn main() {}

impl Solution {
    pub fn third_max(nums: Vec<i32>) -> i32 {
        let mut nums_set = nums.into_iter().collect::<HashSet<i32>>();
        let mut nums_vec = nums_set.into_iter().collect::<Vec<i32>>();
        nums_vec.sort();
        nums_vec.reverse();
        match nums_vec.len() {
            1 | 2 => nums_vec[0],
            _ => nums_vec[2]
        }
    }
}